xen: Some cleanups for x86 start of day.
authorKeir Fraser <keir@xensource.com>
Thu, 10 May 2007 21:54:43 +0000 (22:54 +0100)
committerKeir Fraser <keir@xensource.com>
Thu, 10 May 2007 21:54:43 +0000 (22:54 +0100)
1. Remove erroneous modification to e820.c
2. Make sure Xen is relocated as high as possible below 4GB.
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/e820.c
xen/arch/x86/setup.c

index 72267a71e80f009cccf8d8dbf93cf8e14cf77c5a..95daf54302b48a7d8ecb39aba0ed61ac9bd7b9ed 100644 (file)
@@ -32,7 +32,7 @@ static void __init add_memory_region(unsigned long long start,
     }
 } /* add_memory_region */
 
-/*static*/ void __init print_e820_memory_map(struct e820entry *map, int entries)
+static void __init print_e820_memory_map(struct e820entry *map, int entries)
 {
     int i;
 
index 795dcc947814ffe9860b049c71886e8a60d96515..ea90e800e0661c5fdaac0f733064e66242efebde 100644 (file)
@@ -462,7 +462,7 @@ void __init __start_xen(multiboot_info_t *mbi)
     }
 
     /*
-     * Iterate over all superpage-aligned RAM regions.
+     * Iterate backwards over all superpage-aligned RAM regions.
      * 
      * We require superpage alignment because the boot allocator is not yet
      * initialised. Hence we can only map superpages in the address range
@@ -475,7 +475,7 @@ void __init __start_xen(multiboot_info_t *mbi)
      * x86/64, we relocate Xen to higher memory.
      */
     modules_length = mod[mbi->mods_count-1].mod_end - mod[0].mod_start;
-    for ( i = 0; i < boot_e820.nr_map; i++ )
+    for ( i = boot_e820.nr_map-1; i >= 0; i-- )
     {
         uint64_t s, e, mask = (1UL << L2_PAGETABLE_SHIFT) - 1;
 
@@ -491,19 +491,6 @@ void __init __start_xen(multiboot_info_t *mbi)
             (unsigned long)maddr_to_bootstrap_virt(s),
             s >> PAGE_SHIFT, (e-s) >> PAGE_SHIFT, PAGE_HYPERVISOR);
 
-        /* Is the region suitable for relocating the multiboot modules? */
-        if ( !initial_images_start && ((e-s) >= modules_length) )
-        {
-            e -= modules_length;
-            e &= ~mask;
-            initial_images_start = e;
-            initial_images_end = initial_images_start + modules_length;
-            move_memory(initial_images_start, 
-                        mod[0].mod_start, mod[mbi->mods_count-1].mod_end);
-            if ( s >= e )
-                continue;
-        }
-
 #if defined(CONFIG_X86_64)
         /* Is the region suitable for relocating Xen? */
         if ( !xen_phys_start && (((e-s) >> 20) >= opt_xenheap_megabytes) )
@@ -571,6 +558,16 @@ void __init __start_xen(multiboot_info_t *mbi)
                 "D" (__va(__pa(cpu0_stack))), "c" (STACK_SIZE) : "memory" );
         }
 #endif
+
+        /* Is the region suitable for relocating the multiboot modules? */
+        if ( !initial_images_start && (s < e) && ((e-s) >= modules_length) )
+        {
+            e -= modules_length;
+            initial_images_start = e;
+            initial_images_end = initial_images_start + modules_length;
+            move_memory(initial_images_start, 
+                        mod[0].mod_start, mod[mbi->mods_count-1].mod_end);
+        }
     }
 
     if ( !initial_images_start )